function varargout = bc_1D(varargin)
% BC_1D M-file for bc_1D.fig
%      BC_1D, by itself, creates a new BC_1D or raises the existing
%      singleton*.
%
%      H = BC_1D returns the handle to a new BC_1D or the handle to
%      the existing singleton*.
%
%      BC_1D('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BC_1D.M with the given input arguments.
%
%      BC_1D('Property','Value',...) creates a new BC_1D or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before bc_1D_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to bc_1D_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help bc_1D

% Last Modified by GUIDE v2.5 16-Apr-2012 12:40:15

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @bc_1D_OpeningFcn, ...
                   'gui_OutputFcn',  @bc_1D_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before bc_1D is made visible.
function bc_1D_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to bc_1D (see VARARGIN)

% Choose default command line output for bc_1D
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes bc_1D wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global data;
data.param.Gcierre = true;

if (~isempty(data.param.lp_H))
    set(handles.rb_lp_rc,'Value',1.0);
    set(handles.edit_lp_rc1,'String',num2str(data.param.lp_H));
    set(handles.edit_lp_rc2,'String',num2str(data.param.lp_Tref));
    set(handles.edit_lp_rc3,'String',num2str(data.param.lp_q));
    set(handles.rb_lp_dc,'Value',0.0);
elseif (~isempty(data.param.lp_q))
    set(handles.rb_lp_nc,'Value',1.0);
    set(handles.edit_lp_nc,'String',num2str(data.param.lp_q));
    set(handles.rb_lp_dc,'Value',0.0);
elseif (~isempty(data.param.lp_Tref))
    set(handles.rb_lp_dc,'Value',1.0);
    set(handles.edit_lp_dc,'String',num2str(data.param.lp_Tref));
end

if (~isempty(data.param.rp_H))
    set(handles.rb_rp_rc,'Value',1.0);
    set(handles.edit_rp_rc1,'String',num2str(data.param.rp_H));
    set(handles.edit_rp_rc2,'String',num2str(data.param.rp_Tref));
    set(handles.edit_rp_rc3,'String',num2str(data.param.rp_q));
    set(handles.rb_rp_dc,'Value',0.0);
elseif (~isempty(data.param.rp_q))
    set(handles.rb_rp_nc,'Value',1.0);
    set(handles.edit_rp_nc,'String',num2str(data.param.rp_q));
    set(handles.rb_rp_dc,'Value',0.0);
elseif (~isempty(data.param.rp_Tref))
    set(handles.rb_rp_dc,'Value',1.0);
    set(handles.edit_rp_dc,'String',num2str(data.param.rp_Tref));
end

if (data.param.cust_temp==0 && data.param.temporal==0)
    set(handles.uipanel3,'Visible','off');
elseif data.param.cust_ini_sol
    set(handles.rb_cust_is,'Value',1.0);
    set(handles.rb_const_is,'Value',0.0);
    set(handles.edit_const_is,'Enable','Off');
else
    set(handles.rb_const_is,'Value',1.0);
    set(handles.edit_const_is,'String',num2str(data.param.const_ini_sol))
end

% --- Outputs from this function are returned to the command line.
function varargout = bc_1D_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in rb_const_is.
function rb_const_is_Callback(hObject, eventdata, handles)
% hObject    handle to rb_const_is (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_const_is
if(get(hObject,'Value'))
    set(handles.edit_const_is,'Enable','On')
    set(handles.rb_cust_is,'Value',0.0)
else
    set(handles.edit_const_is,'Enable','Off')
end

% --- Executes on button press in rb_cust_is.
function rb_cust_is_Callback(hObject, eventdata, handles)
% hObject    handle to rb_cust_is (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_cust_is
if(get(hObject,'Value'))
    set(handles.rb_const_is,'Value',0.0)
    set(handles.edit_const_is,'Enable','Off')
end

function edit_const_is_Callback(hObject, eventdata, handles)
% hObject    handle to edit_const_is (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_const_is as text
%        str2double(get(hObject,'String')) returns contents of edit_const_is as a double


% --- Executes during object creation, after setting all properties.
function edit_const_is_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_const_is (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox4


% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox5


% --- Executes on button press in checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox6



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox1


% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox2


% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox3



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_dc as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_dc as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_nc as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_nc as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_rc2 as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_rc2 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_rc1 as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_rc1 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_rp_dc_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_dc as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_dc as a double


% --- Executes during object creation, after setting all properties.
function edit_rp_dc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_rp_nc_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_nc as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_nc as a double


% --- Executes during object creation, after setting all properties.
function edit_rp_nc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_rp_rc2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_rc2 as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_rc2 as a double


% --- Executes during object creation, after setting all properties.
function edit_rp_rc2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_rp_rc1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_rc1 as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_rc1 as a double


% --- Executes during object creation, after setting all properties.
function edit_rp_rc1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in rb_rp_dc.
function rb_rp_dc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_rp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_rp_dc
if(get(hObject,'Value'))
    set(handles.edit_rp_dc,'Enable','On')
    set(handles.rb_rp_nc,'Value',0.0)
    set(handles.rb_rp_rc,'Value',0.0)
    set(handles.edit_rp_nc,'Enable','Off')
    set(handles.edit_rp_rc1,'Enable','Off')
    set(handles.edit_rp_rc2,'Enable','Off')
    set(handles.edit_rp_rc3,'Enable','Off')
    set(handles.edit_rp_nc,'String','')
    set(handles.edit_rp_rc1,'String','')
    set(handles.edit_rp_rc2,'String','')
    set(handles.edit_rp_rc3,'String','')
else
    set(handles.edit_rp_dc,'Enable','Off')
end

% --- Executes on button press in rb_rp_nc.
function rb_rp_nc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_rp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_rp_nc
if(get(hObject,'Value'))
    set(handles.edit_rp_nc,'Enable','On')
    set(handles.rb_rp_dc,'Value',0.0)
    set(handles.rb_rp_rc,'Value',0.0)
    set(handles.edit_rp_dc,'Enable','Off')
    set(handles.edit_rp_rc1,'Enable','Off')
    set(handles.edit_rp_rc2,'Enable','Off')
    set(handles.edit_rp_rc3,'Enable','Off')
    set(handles.edit_rp_dc,'String','')
    set(handles.edit_rp_rc1,'String','')
    set(handles.edit_rp_rc2,'String','')
    set(handles.edit_rp_rc3,'String','')
else
    set(handles.edit_rp_nc,'Enable','Off')
end

% --- Executes on button press in rb_rp_rc.
function rb_rp_rc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_rp_rc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_rp_rc
if(get(hObject,'Value'))
    set(handles.edit_rp_rc1,'Enable','On')
    set(handles.edit_rp_rc2,'Enable','On')
    set(handles.edit_rp_rc3,'Enable','On')
    set(handles.rb_rp_dc,'Value',0.0)
    set(handles.rb_rp_nc,'Value',0.0)
    set(handles.edit_rp_dc,'Enable','Off')
    set(handles.edit_rp_nc,'Enable','Off')
    set(handles.edit_rp_dc,'String','')
    set(handles.edit_rp_nc,'String','')
else
    set(handles.edit_rp_rc1,'Enable','Off')
    set(handles.edit_rp_rc2,'Enable','Off')
    set(handles.edit_rp_rc3,'Enable','Off')
end


function edit_rp_rc3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_rp_rc3 as text
%        str2double(get(hObject,'String')) returns contents of edit_rp_rc3 as a double


% --- Executes during object creation, after setting all properties.
function edit_rp_rc3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rp_rc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in rb_lp_dc.
function rb_lp_dc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_lp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_lp_dc
if(get(hObject,'Value'))
    set(handles.edit_lp_dc,'Enable','On')
    set(handles.rb_lp_nc,'Value',0.0)
    set(handles.rb_lp_rc,'Value',0.0)
    set(handles.edit_lp_nc,'Enable','Off')
    set(handles.edit_lp_rc1,'Enable','Off')
    set(handles.edit_lp_rc2,'Enable','Off')
    set(handles.edit_lp_rc3,'Enable','Off')
    set(handles.edit_lp_nc,'String','')
    set(handles.edit_lp_rc1,'String','')
    set(handles.edit_lp_rc2,'String','')
    set(handles.edit_lp_rc3,'String','')
else
    set(handles.edit_lp_dc,'Enable','Off')
end

% --- Executes on button press in rb_lp_nc.
function rb_lp_nc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_lp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_lp_nc
if(get(hObject,'Value'))
    set(handles.edit_lp_nc,'Enable','On')
    set(handles.rb_lp_dc,'Value',0.0)
    set(handles.rb_lp_rc,'Value',0.0)
    set(handles.edit_lp_dc,'Enable','Off')
    set(handles.edit_lp_rc1,'Enable','Off')
    set(handles.edit_lp_rc2,'Enable','Off')
    set(handles.edit_lp_rc3,'Enable','Off')
    set(handles.edit_lp_dc,'String','')
    set(handles.edit_lp_rc1,'String','')
    set(handles.edit_lp_rc2,'String','')
    set(handles.edit_lp_rc3,'String','')
else
    set(handles.edit_lp_nc,'Enable','Off')
end

% --- Executes on button press in rb_lp_rc.
function rb_lp_rc_Callback(hObject, eventdata, handles)
% hObject    handle to rb_lp_rc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of rb_lp_rc
if(get(hObject,'Value'))
    set(handles.edit_lp_rc1,'Enable','On')
    set(handles.edit_lp_rc2,'Enable','On')
    set(handles.edit_lp_rc3,'Enable','On')
    set(handles.rb_lp_dc,'Value',0.0)
    set(handles.rb_lp_nc,'Value',0.0)
    set(handles.edit_lp_dc,'String','')
    set(handles.edit_lp_nc,'String','')
    set(handles.edit_lp_dc,'String','')
    set(handles.edit_lp_nc,'String','')
else
    set(handles.edit_lp_rc1,'Enable','Off')
    set(handles.edit_lp_rc2,'Enable','Off')
    set(handles.edit_lp_rc3,'Enable','Off')
end


function edit_lp_dc_Callback(hObject, eventdata, handles)
% hObject    handle to edit_lp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_lp_dc as text
%        str2double(get(hObject,'String')) returns contents of edit_lp_dc as a double


% --- Executes during object creation, after setting all properties.
function edit_lp_dc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_lp_dc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_lp_nc_Callback(hObject, eventdata, handles)
% hObject    handle to edit_lp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_lp_nc as text
%        str2double(get(hObject,'String')) returns contents of edit_lp_nc as a double


% --- Executes during object creation, after setting all properties.
function edit_lp_nc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_lp_nc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_lp_rc2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_lp_rc2 as text
%        str2double(get(hObject,'String')) returns contents of edit_lp_rc2 as a double


% --- Executes during object creation, after setting all properties.
function edit_lp_rc2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_lp_rc1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_lp_rc1 as text
%        str2double(get(hObject,'String')) returns contents of edit_lp_rc1 as a double


% --- Executes during object creation, after setting all properties.
function edit_lp_rc1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_lp_rc3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_lp_rc3 as text
%        str2double(get(hObject,'String')) returns contents of edit_lp_rc3 as a double


% --- Executes during object creation, after setting all properties.
function edit_lp_rc3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_lp_rc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data;
data.param.Gcierre = false;

close bc_1D
geo_3

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data;
data.param.Gcierre = false;
correct=1;
ltype = '';
rtype = '';
if (get(handles.rb_lp_dc,'Value'))
    if isempty(str2num(get(handles.edit_lp_dc,'String')))
        correct=0;
    else
        lp_Tref=str2num(get(handles.edit_lp_dc,'String'));
        lp_q = [];lp_H = [];
        ltype = 'DIRICHLET';
    end
elseif (get(handles.rb_lp_nc,'Value'))
    if isempty(str2num(get(handles.edit_lp_nc,'String')))
        correct=0;
    else
        lp_q=str2num(get(handles.edit_lp_nc,'String'));
        ltype = 'NEUMANN';
        lp_Tref = [];lp_H = [];
    end
elseif (get(handles.rb_lp_rc,'Value'))
    if isempty(str2num(get(handles.edit_lp_rc1,'String')))
        correct=0;
    elseif isempty(str2num(get(handles.edit_lp_rc2,'String')))
        correct=0;
    elseif isempty(str2num(get(handles.edit_lp_rc3,'String')))
        correct=0;
    else
        lp_H=str2num(get(handles.edit_lp_rc1,'String'));
        lp_Tref=str2num(get(handles.edit_lp_rc2,'String'));
        lp_q=str2num(get(handles.edit_lp_rc3,'String'));
        ltype = 'MIXED';
    end
end

if (get(handles.rb_rp_dc,'Value'))
    if isempty(str2num(get(handles.edit_rp_dc,'String')))
        correct=0;
    else
        rp_Tref=str2num(get(handles.edit_rp_dc,'String'));
        rp_q = [];rp_H = [];
        rtype = 'DIRICHLET';
    end
elseif (get(handles.rb_rp_nc,'Value'))
    if isempty(str2num(get(handles.edit_rp_nc,'String')))
        correct=0;
    else
        rp_q=str2num(get(handles.edit_rp_nc,'String'));
        rp_Tref = [];rp_H = [];
        rtype = 'NEUMANN';
    end
elseif (get(handles.rb_rp_rc,'Value'))
    if isempty(str2num(get(handles.edit_rp_rc1,'String')))
        correct=0;
    elseif isempty(str2num(get(handles.edit_rp_rc2,'String')))
        correct=0;
    elseif isempty(str2num(get(handles.edit_rp_rc3,'String')))
        correct=0;
    else
        rp_H=str2num(get(handles.edit_rp_rc1,'String'));
        rp_Tref=str2num(get(handles.edit_rp_rc2,'String'));
        rp_q=str2num(get(handles.edit_rp_rc3,'String'));
        rtype = 'MIXED';
    end
end

%completo los parametros en el struct param
set(data.param,{'lp_H','lp_Tref','lp_q'},num2cell({lp_H,lp_Tref,lp_q}));
set(data.param,{'rp_H','rp_Tref','rp_q'},num2cell({rp_H,rp_Tref,rp_q}));

%una vez conocidos los parametros, armo los patches
data.patchs(2) = Patch;
xnod = cell2mat(get(data.mesh.nodes,'x'));
icone = cell2mat(get(data.mesh.eles,'icone'));
[xmin,imin] = min(xnod);
[xmax,imax] = max(xnod);

l_iele = find(icone(:,1)==imin);
r_iele = find(icone(:,2)==imax);
set(data.patchs(1),{'border','type','H','q','Tref','nodes','ele_faces'},num2cell({'LEFT',ltype,lp_H,lp_q,lp_Tref,imin,[l_iele,1]}));
set(data.patchs(2),{'border','type','H','q','Tref','nodes','ele_faces'},num2cell({'RIGHT',rtype,rp_H,rp_q,rp_Tref,imax,[r_iele,2]}));

if (data.param.cust_temp) || (data.param.temporal ~= 0)
    if (get(handles.rb_const_is,'Value'))
        if isempty(str2num(get(handles.edit_const_is,'String')))
            correct=0;
        else
            const_is=str2num(get(handles.edit_const_is,'String'));
            set(data.param,{'const_ini_sol'},num2cell({const_is}));
        end
    else
        data.param.cust_ini_sol=true;
        if (correct)
            filename = strcat([data.param.Gdirec,'/custom_inisolution.m']);
            s = ['edit ' filename];
            eval(s) 
            hh = warndlg('Custom initial solution must be programmed before run the problem. Matlab editor, with these files, has been opened.','caution','modal'); 
            uiwait(hh);
        end
    end
end

if (correct)
    close bc_1D
    simul
else
    warndlg('Input must be numerical');
    data.param.Gcierre = true;
end


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
global data;
if (data.param.Gcierre)
    resp=questdlg('Está seguro que desea salir?','EduFEM');
    if strcmp(resp,'Yes')
        save(strcat(data.param.Gdirec,'/data'), 'data');
        delete(hObject);
    end
else
    delete(hObject);
end


